FROM tomcat:9.0-jdk8

# 删除默认的ROOT应用
RUN rm -rf /usr/local/tomcat/webapps/*

# 创建webapps目录
RUN mkdir -p /usr/local/tomcat/webapps/ROOT

# 复制配置文件
COPY conf/server.xml /usr/local/tomcat/conf/
COPY conf/context.xml /usr/local/tomcat/conf/

# 添加等待脚本
COPY wait-for-it.sh /wait-for-it.sh
RUN chmod +x /wait-for-it.sh

# 设置工作目录
WORKDIR /usr/local/tomcat

# 暴露端口
EXPOSE 8080

# 等待MySQL启动后再启动Tomcat
CMD ["/bin/bash", "-c", "/wait-for-it.sh summer_mysql:3306 -t 60 -- catalina.sh run"] 